<!DOCTYPE html>
<html lang="en" style="font-size: 100px">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #banner{
            width: 3rem;
            height :0.5rem;
            border:solid 0.01rem #000;
            margin: 0.5rem auto;
        }

        #banner2{
            width: 3rem;
            height :0.5rem;
            border:solid 1px #000;
            margin: 0.5rem auto;
        }
    </style>
</head>
<body>
    <div id="banner"></div>
    <div id="banner2"></div>

    <script>
        let size;
        function adapter(){
            size = document.documentElement.clientWidth * 100 / 375;
            document.documentElement.style.fontSize = size + 'px';
        }
        adapter();
        // window.onresize = adapter;

        //1. rem 单位布局  375 - 100
        //2. 边框的单位要使用 px 
        //3. 缩小页面整体显示比例  initial-scale   独立像素 / 布局视口大小
        let viewport = document.querySelector('meta[name=viewport]');
        //修改 viewport 的 initial-scale
        viewport.setAttribute('content','initial-scale='+1/window.devicePixelRatio);
        //修改根标签的 font-size 的值
        document.documentElement.style.fontSize = size * window.devicePixelRatio + 'px';

    </script>
</body>
</html>